library(data.table)
library(rstan)
source("functions.R")
load("analysis_data.RData")
load("results-2023-08-04.RData")

# reported quantities ----
mean(payoffs)
range(payoffs)

receiver_data[Condition == "Numeric", cor.test(Action, Target)]
receiver_data[Condition == "Text", cor.test(Action, Target)]

mean(rowSums(extract(m_payoff_sender$stanfit)$beta[, c(1, 3)]))
quantile(rowSums(extract(m_payoff_sender$stanfit)$beta[, c(1, 3)]),
  c(.025, .975))
mean(rowSums(extract(m_payoff_receiver$stanfit)$beta[, c(1, 3)]))
quantile(rowSums(extract(m_payoff_receiver$stanfit)$beta[, c(1, 3)]),
  c(.025, .975))
mean(rowSums(extract(m_pareto$stanfit)$beta[, c(1, 3)]))
quantile(rowSums(extract(m_pareto$stanfit)$beta[, c(1, 3)]), c(.025, .975))


receiver_data[, .(
  mean(abs(Target - Action)),
  sd(abs(Target - Action)) / sqrt(.N) - 1), Condition][, .(
    Condition, V1, V1 + qnorm(.025) * V2,V1 + qnorm(.975) * V2
  )]
